<?php
/**
 * Created by PhpStorm.
 * User: xaq
 * Date: 2017/5/21
 * Time: 0:09
 */

namespace app\api\controller\v1;

use app\api\controller\BaseController;
use think\Controller;
use app\api\model\Category as CategoryModel;

class Category extends BaseController
{
    /**
     * @url /api/v1/category/all
     */
    public function getAllCategories(){
        //$categories = CategoryModel::all([],'img');
        $categories = CategoryModel::with('img')->select();
        if($categories->isEmpty()){
            throw new CategoryException();
        }
        return $categories;
    }
}